home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Src / stklos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-24  |  3.3 KB  |  91 lines

  1. /*
  2.  *
  3.  *  s t k l o s . h            -- STklos support
  4.  *
  5.  * Copyright ⌐ 1993-1996 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
  6.  * 
  7.  *
  8.  * Permission to use, copy, and/or distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted, provided
  10.  * that both the above copyright notice and this permission notice appear in
  11.  * all copies and derived works.  Fees for distribution or use of this
  12.  * software or derived works may only be charged with express written
  13.  * permission of the copyright holder.  
  14.  * This software is provided ``as is'' without express or implied warranty.
  15.  *
  16.  * This software is a derivative work of other copyrighted softwares; the
  17.  * copyright notices of these softwares are placed in the file COPYRIGHTS
  18.  *
  19.  *
  20.  *            Author: Erick Gallesio [eg@unice.fr]
  21.  *    Creation date:  9-Feb-1994 15:56
  22.  * Last file update: 24-Jul-1996 17:04 
  23.  */
  24.  
  25. typedef struct stklos_instance {
  26.   char instance_type;
  27.   SCM classe;              /* Name is choosed to avoid conflicts with C++ */
  28.   SCM accessors;
  29.   int number_of_slots;
  30.   SCM slots[1];            /* Must be last !! */
  31. } Instance;
  32.  
  33.  
  34. #define TYPE_INSTANCE        00
  35. #define TYPE_GENERIC        01
  36.  
  37.  
  38. #define INST(x)                ((x)->storage_as.instance.data)
  39. #define INSTID(x)        ((x)->storage_as.instance.id)
  40. #define CLASS_OF(x)         (INST(x)->classe)
  41. #define INST_TYPE(x)        (INST(x)->instance_type)
  42. #define ACCESSORS_OF(x)     (INST(x)->accessors)
  43. #define NUMBER_OF_SLOTS(x)  (INST(x)->number_of_slots)
  44. #define INSTANCEP(x)        (TYPEP(x, tc_instance))
  45. #define NINSTANCEP(x)        (NTYPEP(x, tc_instance))
  46. #define PUREGENERICP(x)        (INSTANCEP(x) && (INST(x)->instance_type&TYPE_GENERIC))
  47.  
  48. #define THE_SLOT_OF(x, i)   (INST(x)->slots[i])
  49. #define SUBCLASSP(c1, c2)   (STk_memq(c2, THE_SLOT_OF(c1, S_cpl)) != Ntruth)
  50.  
  51. #define NXT_GF(x)        (CAR(CAR(x))
  52. #define NXT_METHODS(x)        (CDR(CAR(x))
  53. #define NXT_ARGS(x)        (CDR(x))
  54.  
  55.  
  56. #define S_name             0     /*a symbol*/
  57. #define S_direct_supers     1     /* (class ...) */
  58. #define S_direct_slots        2     /* ((name . options) ...) */
  59. #define S_cpl            3     /* (class ...) */
  60. #define S_slots            4    /* ((name . options) ...) */
  61. #define S_nfields        5    /* an integer */
  62. #define S_initializers        6    /* (proc ...) */
  63. #define S_getters_n_setters    7    /* ((slot getter setter) ...) */
  64. #define NUMBER_OF_CLASS_SLOTS    8    
  65.  
  66.  
  67. #define S_methods        1    /* offset of methods slot in a <generic> */
  68.  
  69. #define S_generic_function    0    /* offset of gf    slot in a <method> */
  70. #define S_specializers        1    /* offset of spec. slot in a <method> */
  71. #define S_procedure         2    /* offset of proc. slot in a <method> */
  72.  
  73. #define STk_tc_instance tc_instance    /* for compatibility with older versions */
  74. #define clath        classe        /* for compatibility with older versions */
  75.  
  76. /* Low level functions exported */
  77. SCM STk_make_instance(SCM classe, long  size, int type);
  78. SCM STk_make_next_method(SCM methods, SCM args);
  79. SCM STk_basic_make_class(SCM classe, SCM name, SCM dsupers, SCM dslots);
  80. SCM STk_apply_generic(SCM gf, SCM args);
  81.  
  82.  
  83. PRIMITIVE STk_allocate_instance(SCM classe);
  84. PRIMITIVE STk_slot_ref(SCM obj, SCM slot_name);
  85. PRIMITIVE STk_slot_set(SCM obj, SCM slot_name, SCM value);
  86. PRIMITIVE STk_class_of(SCM obj);
  87.  
  88. SCM STk_compute_applicable_methods(SCM gf, SCM args, int len, int find_method);
  89. SCM STk_apply_user_generic(SCM gf, SCM args);
  90. SCM STk_apply_next_method(SCM next, SCM provided_args);
  91.